//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "DefaultEvent.h"
using namespace Cephei::QL::Experimental::Credit;
#include <gen/QL/Currency.h>
#include <gen/QL/Experimental/Credit/DefaultType.h>
#include <gen/QL/Experimental/Credit/DefaultProbKey.h>
#include <gen/QL/Event.h>
using namespace Cephei::QL;
#define HANDLE
#define ABSTRACT
#undef STRUCT
Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (boost::shared_ptr<QuantLib::DefaultEvent>& childNative, Object^ owner) : CEvent(CDefaultEvent::typeid)
{
#ifdef HANDLE
	_phDefaultEvent = NULL;
#endif
	_ppDefaultEvent = &childNative;
    _ppEvent = new boost::shared_ptr<QuantLib::Event> (boost::dynamic_pointer_cast<QuantLib::Event> (*_ppDefaultEvent));
}
Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (QuantLib::DefaultEvent& childNative, Object^ owner) : CEvent(CDefaultEvent::typeid)
{
#ifdef HANDLE
	_phDefaultEvent = NULL;
#endif
	_ppDefaultEvent = new boost::shared_ptr<QuantLib::DefaultEvent> (&childNative);
    _ppEvent = new boost::shared_ptr<QuantLib::Event> (boost::dynamic_pointer_cast<QuantLib::Event> (*_ppDefaultEvent));
    _DefaultEventOwner = owner;
    _EventOwner = owner;
}

Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (CDefaultEvent^ copy) : CEvent(CDefaultEvent::typeid)
{
#ifdef HANDLE
	_phDefaultEvent = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppDefaultEvent = new boost::shared_ptr<QuantLib::DefaultEvent> (copy->GetShared());
        _ppEvent = new boost::shared_ptr<QuantLib::Event> (boost::dynamic_pointer_cast<QuantLib::Event> (*_ppDefaultEvent));
    }
}
Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (PLATFORM::Type^ t) : CEvent(CDefaultEvent::typeid)
{
#ifdef HANDLE
	_phDefaultEvent = NULL;
#endif
	if (!t->IsSubclassOf(CDefaultEvent::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (QuantLib::Handle<QuantLib::DefaultEvent>& childNative, Object^ owner)  : CEvent(CDefaultEvent::typeid)
{
	_phDefaultEvent = &childNative;
	_ppDefaultEvent = &static_cast<boost::shared_ptr<QuantLib::DefaultEvent>>(childNative.currentLink());
    _ppEvent = new boost::shared_ptr<QuantLib::Event> (boost::dynamic_pointer_cast<QuantLib::Event> (*_ppDefaultEvent));
    _DefaultEventOwner = owner;
}
Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (QuantLib::Handle<QuantLib::DefaultEvent> childNative)  : CEvent(CDefaultEvent::typeid)
{
	_phDefaultEvent = &childNative;
	_ppDefaultEvent = &static_cast<boost::shared_ptr<QuantLib::DefaultEvent>>(childNative.currentLink());
    _ppEvent = new boost::shared_ptr<QuantLib::Event> (boost::dynamic_pointer_cast<QuantLib::Event> (*_ppDefaultEvent));
}
#endif
#ifdef STRUCT
Cephei::QL::Experimental::Credit::CDefaultEvent::CDefaultEvent (QuantLib::DefaultEvent childNative)  : CEvent(CDefaultEvent::typeid)
{
#ifdef HANDLE
	_phDefaultEvent = NULL;
#endif
	_ppDefaultEvent = new boost::shared_ptr<QuantLib::DefaultEvent> (new QuantLib::DefaultEvent (childNative));
    _ppEvent = new boost::shared_ptr<QuantLib::Event> (boost::dynamic_pointer_cast<QuantLib::Event> (*_ppDefaultEvent));
}
#endif

Cephei::QL::Experimental::Credit::CDefaultEvent::~CDefaultEvent ()
{
    if (_ppDefaultEvent != NULL)
    {
	    delete _ppDefaultEvent;
        _ppDefaultEvent = NULL;
    }
}
Cephei::QL::Experimental::Credit::CDefaultEvent::!CDefaultEvent ()
{
    if (_ppDefaultEvent != NULL)
    {
	    delete _ppDefaultEvent;
    }
}
QuantLib::DefaultEvent& Cephei::QL::Experimental::Credit::CDefaultEvent::GetReference ()
{
    if (_ppDefaultEvent == NULL) throw REFNEW NativeNullException ();
	return **_ppDefaultEvent;
}
boost::shared_ptr<QuantLib::DefaultEvent>& Cephei::QL::Experimental::Credit::CDefaultEvent::GetShared ()
{
    if (_ppDefaultEvent == NULL) throw REFNEW NativeNullException ();
	return *_ppDefaultEvent;
}
QuantLib::DefaultEvent* Cephei::QL::Experimental::Credit::CDefaultEvent::GetPointer ()
{
    if (_ppDefaultEvent == NULL) throw REFNEW NativeNullException ();
	return &**_ppDefaultEvent;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::DefaultEvent>& Cephei::QL::Experimental::Credit::CDefaultEvent::GetHandle ()
{
	if (_phDefaultEvent == NULL)
	{
		_phDefaultEvent = new Handle<QuantLib::DefaultEvent> (*_ppDefaultEvent);
	}
	return *_phDefaultEvent;
}
#endif
bool Cephei::QL::Experimental::Credit::CDefaultEvent::HasNative () 
{
	return (_ppDefaultEvent != NULL);
}

Cephei::QL::ICurrency^ Cephei::QL::Experimental::Credit::CDefaultEvent::Currency::get ()
{
    try
    {
    	QuantLib::Currency& _rv = (QuantLib::Currency&)(*_ppDefaultEvent)->currency ( );   
        Cephei::QL::CCurrency^ _nrv = REFNEW Cephei::QL::CCurrency (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Experimental::Credit::CDefaultEvent::Date::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppDefaultEvent)->date ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Credit::IDefaultType^ Cephei::QL::Experimental::Credit::CDefaultEvent::DefaultType::get ()
{
    try
    {
    	QuantLib::DefaultType& _rv = (QuantLib::DefaultType&)(*_ppDefaultEvent)->defaultType ( );   
        Cephei::QL::Experimental::Credit::CDefaultType^ _nrv = REFNEW Cephei::QL::Experimental::Credit::CDefaultType (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Experimental::Credit::SeniorityEnum Cephei::QL::Experimental::Credit::CDefaultEvent::EventSeniority::get ()
{
    try
    {
    	QuantLib::Seniority _rv = (QuantLib::Seniority)(*_ppDefaultEvent)->eventSeniority ( );   
        QL::Experimental::Credit::SeniorityEnum _nrv = (QL::Experimental::Credit::SeniorityEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Experimental::Credit::CDefaultEvent::HasSettled::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppDefaultEvent)->hasSettled ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Experimental::Credit::CDefaultEvent::IsDefault::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppDefaultEvent)->isDefault ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Experimental::Credit::CDefaultEvent::IsRestructuring::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppDefaultEvent)->isRestructuring ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Experimental::Credit::CDefaultEvent::MatchesDefaultKey (Cephei::QL::Experimental::Credit::IDefaultProbKey^ contractKey)
{
    CDefaultProbKey^ _CcontractKey;
    try
    {
        _CcontractKey = safe_cast<CDefaultProbKey^> (contractKey);
        _CcontractKey->Lock();
        QuantLib::DefaultProbKey& _contractKey = static_cast<QuantLib::DefaultProbKey&> (_CcontractKey->GetReference ()); 
    	bool _rv = (bool)(*_ppDefaultEvent)->matchesDefaultKey ( _contractKey );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_CcontractKey != nullptr) _CcontractKey->Unlock();
    }
}
Boolean Cephei::QL::Experimental::Credit::CDefaultEvent::MatchesEventType (Cephei::QL::Experimental::Credit::IDefaultType^ contractEvType)
{
    CDefaultType^ _CcontractEvType;
    try
    {
        _CcontractEvType = safe_cast<CDefaultType^> (contractEvType);
        _CcontractEvType->Lock();
        boost::shared_ptr<QuantLib::DefaultType>& _contractEvType = static_cast<boost::shared_ptr<QuantLib::DefaultType>&> (_CcontractEvType->GetShared ()); 
    	bool _rv = (bool)(*_ppDefaultEvent)->matchesEventType ( _contractEvType );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_CcontractEvType != nullptr) _CcontractEvType->Unlock();
    }
}
Double Cephei::QL::Experimental::Credit::CDefaultEvent::RecoveryRate (QL::Experimental::Credit::SeniorityEnum seniority)
{
    try
    {
        QuantLib::Seniority _seniority = (QuantLib::Seniority)seniority ;
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppDefaultEvent)->recoveryRate ( _seniority );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Experimental::Credit::CDefaultEventVector::CDefaultEventVector ()
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
}
Cephei::QL::Experimental::Credit::CDefaultEventVector::~CDefaultEventVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
Cephei::QL::Experimental::Credit::CDefaultEventVector::!CDefaultEventVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
#endif
}
#ifdef STRUCT
Cephei::QL::Experimental::Credit::CDefaultEventVector::CDefaultEventVector (std::vector<QuantLib::DefaultEvent>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = &vec;
	_owner = owner;
}
Cephei::QL::Experimental::Credit::CDefaultEventVector::CDefaultEventVector (std::vector<QuantLib::DefaultEvent> vec)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = new std::vector<QuantLib::DefaultEvent> (vec);
}
#endif
Cephei::QL::Experimental::Credit::CDefaultEventVector::CDefaultEventVector (std::vector<boost::shared_ptr<QuantLib::DefaultEvent>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVBoost = &vec;
	_owner = owner;
}
#ifdef HANDLE
Cephei::QL::Experimental::Credit::CDefaultEventVector::CDefaultEventVector (std::vector<QuantLib::Handle<QuantLib::DefaultEvent>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVHand = &vec;
	_owner = owner;
}
#endif

int Cephei::QL::Experimental::Credit::CDefaultEventVector::Count::get ()
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		return _pVValue->size();
	}
#endif    
	if (_pVBoost != NULL)
	{
		return _pVBoost->size ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		return _pVHand->size ();
	}
#endif
	return 0;		// should never happen
}
Cephei::QL::Experimental::Credit::IDefaultEvent^ Cephei::QL::Experimental::Credit::CDefaultEventVector::default::get (int index) 
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
    	if ((size_t)index >= _pVValue->size()) throw REFNEW RangeException ();
		QuantLib::DefaultEvent& native = (*_pVValue)[index];
		return REFNEW CDefaultEvent (native, this);
	}
#endif    
	if (_pVBoost != NULL)
	{
    	if ((size_t)index >= _pVBoost->size()) throw REFNEW RangeException ();
		QuantLib::DefaultEvent& native = *(*_pVBoost)[index];
		return REFNEW CDefaultEvent (native, this);
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
    	if ((size_t)index >= _pVHand->size()) throw REFNEW RangeException ();
		QuantLib::DefaultEvent& native = *((*_pVHand)[index].currentLink ());
		return REFNEW CDefaultEvent (native, this);
	}
#endif
	return nullptr;		// can never be the case
}
void Cephei::QL::Experimental::Credit::CDefaultEventVector::default::set (int index, Cephei::QL::Experimental::Credit::IDefaultEvent^ value) 
{
#ifdef STRUCT
	if (_pVValue != NULL)
	{
		if (_pVValue->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVValue->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVValue->push_back (dynamic_cast<CDefaultEvent^>(value)->GetReference ());
		}
        else
        {
            QuantLib::DefaultEvent& c = (*_pVValue)[index];
            c = dynamic_cast<CDefaultEvent^>(value)->GetReference ();
        }
	}
#endif   
	if (_pVBoost != NULL)
	{
		if (_pVBoost->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVBoost->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVBoost->push_back (dynamic_cast<CDefaultEvent^>(value)->GetShared ());
		}
		boost::shared_ptr<QuantLib::DefaultEvent>& c = (*_pVBoost)[index];
		c = dynamic_cast<CDefaultEvent^>(value)->GetShared ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if (_pVHand->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVHand->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVHand->push_back (QuantLib::Handle<QuantLib::DefaultEvent> ());
		}
		QuantLib::Handle<QuantLib::DefaultEvent>& c = (*_pVHand)[index];
		boost::shared_ptr<QuantLib::DefaultEvent>& b = static_cast<boost::shared_ptr<QuantLib::DefaultEvent>>(c.currentLink());
		b = dynamic_cast<CDefaultEvent^>(value)->GetShared ();
	}
#endif
}
Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^ Cephei::QL::Experimental::Credit::CDefaultEventVector::CItem::get (int index) 
{
	return CellFactory::Instance->Create<IDefaultEvent^> (dynamic_cast<IDefaultEvent^>(default[index]));
}

void Cephei::QL::Experimental::Credit::CDefaultEventVector::CItem::set (int index, Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^ value) 
{
	default[index] = safe_cast<IDefaultEvent^>(value->Value);
}
#ifdef STRUCT
std::vector<QuantLib::DefaultEvent>& Cephei::QL::Experimental::Credit::CDefaultEventVector::GetReference ()
{
	 return *_pVValue;
}
#endif

std::vector<boost::shared_ptr<QuantLib::DefaultEvent>>& Cephei::QL::Experimental::Credit::CDefaultEventVector::GetShared ()
{
	return *_pVBoost;
}

#ifdef HANDLE
std::vector<QuantLib::Handle<QuantLib::DefaultEvent>>& Cephei::QL::Experimental::Credit::CDefaultEventVector::GetHandle ()
{
	return *_pVHand;
}
#endif
bool Cephei::QL::Experimental::Credit::CDefaultEventVector::PrepareFeature (NativeFeature feature)
{
	switch (feature)
	{
#ifdef STRUCT
		case NativeFeature::Value :
			if (_pVValue == NULL)
			{
				_pVValue = new std::vector<QuantLib::DefaultEvent> ();
				return true;
			}
			break;
#endif
        case NativeFeature::shared_ptr :
			if (_pVBoost == NULL)
			{
				_pVBoost = new std::vector<boost::shared_ptr<QuantLib::DefaultEvent>> ();
				return true;
			}
			break;
#ifdef HANDLE
        case NativeFeature::Handle :
            if (_pVHand == NULL)
            {
                _pVHand = new std::vector<QuantLib::Handle<QuantLib::DefaultEvent>> ();
                return true;
            }
            break;
#endif
	}
	return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

/* <summary>Create a single dimension array of DefaultEvent that can be passed into other function </summary> */
IVector<Cephei::QL::Experimental::Credit::IDefaultEvent^>^ Cephei::QL::Experimental::Credit::CDefaultEvent_Factory::CreateVector ()
 {
	 return REFNEW CoVector<IDefaultEvent^> (REFNEW CDefaultEventVector ());
 }
IVector<Cephei::QL::Experimental::Credit::IDefaultEvent^>^ Cephei::QL::Experimental::Credit::CDefaultEvent_Factory::CreateVector (PLATFORM::Collections::Generic::IEnumerable<IDefaultEvent^>^ source)
 {
	 return REFNEW CoVector<IDefaultEvent^> (source, REFNEW CDefaultEventVector ());
 }
/* <summary>Create a single dimension array of DefaultEvent with change events</summary> */
Cephei::Core::Generic::ICoCell<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^>^>^ Cephei::QL::Experimental::Credit::CDefaultEvent_Factory::CreateCellVector ()
 {
	 return CellFactory::Instance->Create<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^>^> (REFNEW CoCellVector<Cephei::QL::Experimental::Credit::IDefaultEvent^> (REFNEW CDefaultEventVector ()));
 }
Cephei::Core::Generic::ICoCell<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^>^>^ Cephei::QL::Experimental::Credit::CDefaultEvent_Factory::CreateCellVector (PLATFORM::Collections::Generic::IEnumerable<Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^>^ source)
 {
	 return CellFactory::Instance->Create<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Experimental::Credit::IDefaultEvent^>^>^> (REFNEW CoCellVector<Cephei::QL::Experimental::Credit::IDefaultEvent^> (source, REFNEW CDefaultEventVector ()));
 }

